//
//  CargoCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "CargoCell.h"

/************************************************************************/

/**************************商品规格单价单元格***********************************/

/************************************************************************/

@interface CargoCell ()

@property (nonatomic,strong)UIImageView *oStoreImgView;

@property (nonatomic,strong)UILabel *oStoreLab;

@property (nonatomic,strong)UILabel *oEtalonParaLab;

@property (nonatomic,strong)UILabel *oTotalParaLab;

@property (nonatomic,strong)UILabel *oNumberParaLab;

@end



@implementation CargoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    _oStoreImgView = [[UIImageView alloc] init];
    _oStoreImgView.image = [UIImage imageNamed:@"kuwo_logo"];
    [self addSubview:_oStoreImgView];
    [_oStoreImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.top.equalTo(@15);
        make.height.width.equalTo(@58);
    }];
    
    //parameter:商品名
    _oStoreLab = [UILabel new];
    _oStoreLab.textColor = [UIColor blackColor];
    _oStoreLab.font = [UIFont systemFontOfSize:17.5];
    _oStoreLab.textAlignment = NSTextAlignmentLeft;
    _oStoreLab.text = @"奶嘴型 草莓味 乳酸饮料";
    [self addSubview:_oStoreLab];
    [_oStoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@10);
        make.left.equalTo(_oStoreImgView.mas_right).offset(10);
        make.height.equalTo(@17.5);
    }];
    
    
    UILabel *oEtalonConstLab = [UILabel new];
    oEtalonConstLab.textColor = [UIColor grayColor];
    oEtalonConstLab.font = [UIFont systemFontOfSize:14.0];
    oEtalonConstLab.textAlignment = NSTextAlignmentLeft;
    oEtalonConstLab.text = @"规格:";
    [self addSubview:oEtalonConstLab];
    [oEtalonConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oStoreLab.mas_left);
        make.height.equalTo(@13);
        make.top.equalTo(_oStoreLab.mas_bottom).offset(10);
    }];
    
    //parameter:规格
    _oEtalonParaLab = [UILabel new];
    _oEtalonParaLab.textColor = [UIColor grayColor];
    _oEtalonParaLab.font = [UIFont systemFontOfSize:14.0];
    _oEtalonParaLab.textAlignment = NSTextAlignmentLeft;
    _oEtalonParaLab.text = @"100MLx12";
    [self addSubview:_oEtalonParaLab];
    [_oEtalonParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oEtalonConstLab.mas_right).offset(5);
        make.height.equalTo(@14);
        make.top.equalTo(oEtalonConstLab.mas_top);
    }];
    
    //parameter:金额
    _oTotalParaLab = [UILabel new];
    _oTotalParaLab.textColor = [UIColor redColor];
    _oTotalParaLab.font = [UIFont systemFontOfSize:16.0];
    _oTotalParaLab.textAlignment = NSTextAlignmentLeft;
    _oTotalParaLab.text = @"￥59";
    [self addSubview:_oTotalParaLab];
    [_oTotalParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oEtalonConstLab.mas_left);
        make.height.equalTo(@16);
        make.top.equalTo(oEtalonConstLab.mas_bottom).offset(10);
    }];
    
    //parameter:数量
    _oNumberParaLab = [UILabel new];
    _oNumberParaLab.textColor = [UIColor blackColor];
    _oNumberParaLab.font = [UIFont systemFontOfSize:13.0];
    _oNumberParaLab.textAlignment = NSTextAlignmentLeft;
    _oNumberParaLab.text = @"x 20";
    [self addSubview:_oNumberParaLab];
    [_oNumberParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-15);
        make.height.equalTo(@13);
        make.top.equalTo(_oTotalParaLab.mas_top);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwColor(@"#eeeeee");
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(_oStoreImgView.mas_bottom).offset(15);
        make.height.equalTo(@1.5);
        make.bottom.equalTo(@0);
    }];
    
}

- (void)setModel:(ESSInventoryModel *)model
{
    [_oStoreImgView sd_setImageWithURL:[NSURL URLWithString:model.thumbnail] placeholderImage:kImg(kPlacehodelImg)];
    _oStoreLab.text = [NSString stringWithFormat:@"%@ %@",model.productName,model.tasteName];
    _oEtalonParaLab.text = model.specificationsName;
    _oTotalParaLab.text = [NSString stringWithFormat:@"¥%@",model.price];
    _oNumberParaLab.text = [NSString stringWithFormat:@"x%@",model.totalBox];

}

- (void)setOrderModel:(OrderDetailListModel *)orderModel
{
    
    [_oStoreImgView sd_setImageWithURL:[NSURL URLWithString:orderModel.kwProductAttribute.thumbnail] placeholderImage:kImg(kPlacehodelImg)];
    NSArray *array = [orderModel.productName componentsSeparatedByString:@","];
    NSString *proStr;
    NSString *specificationStr;
    if (array.count > 1)
    {
        proStr = [NSString stringWithFormat:@"%@ %@",array[0]?:@"",array[1]]?:@"";
    }
    else
    {
        proStr = [NSString stringWithFormat:@"%@",array[0]?:@""];
    }
    
    if (array.count > 2)
    {
        specificationStr = [NSString stringWithFormat:@"%@",array[2]?:@""];
    }
    
    _oStoreLab.text = [NSString stringWithFormat:@"%@",proStr?:@""];
    _oEtalonParaLab.text = specificationStr;
    _oTotalParaLab.text = [NSString stringWithFormat:@"¥%@",orderModel.price];
    _oNumberParaLab.text = [NSString stringWithFormat:@"x%@",orderModel.quantity];
}

- (void)setSaCargoModel:(SADetailCargoModel *)saCargoModel
{
    [_oStoreImgView sd_setImageWithURL:[NSURL URLWithString:saCargoModel.kwProductAttribute.thumbnail] placeholderImage:kImg(kPlacehodelImg)];
    _oStoreLab.text = [NSString stringWithFormat:@"%@ %@",saCargoModel.kwProductAttribute.product.productName,saCargoModel.kwProductAttribute.tasteStr];
    _oEtalonParaLab.text = saCargoModel.kwProductAttribute.specificationsStr;
    _oTotalParaLab.text = [NSString stringWithFormat:@"¥%@",saCargoModel.kwProductAttribute.price];
    _oNumberParaLab.text = [NSString stringWithFormat:@"x%@",saCargoModel.quantity];
}
- (void)setEnterModel:(EnterCostListModel *)enterModel
{
//    NSLog(@"=======%@",enterModel);
//    [_oStoreImgView sd_setImageWithURL:[NSURL URLWithString:enterModel.kwApproachApplicationProduct.OrderAttributeModel.kwProductAttribute.thumbnail] placeholderImage:kImg(kPlacehodelImg)];
//    _oStoreLab.text = [NSString stringWithFormat:@"%@ %@",enterModel.kwProductAttribute.product.productName,enterModel.kwProductAttribute.tasteStr];
//    _oEtalonParaLab.text = enterModel.kwProductAttribute.specificationsStr;
//    _oTotalParaLab.text = [NSString stringWithFormat:@"¥%@",EnterModel.kwProductAttribute.price];
//    _oNumberParaLab.text = [NSString stringWithFormat:@"x%@",enterModel.quantity];
    
}


@end
